///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_CV_CROWSIZZLER_H_
#define _BUOLA_CV_CROWSIZZLER_H_

#include <buola/utility/cpoint.h>

namespace buola { namespace img {

class CRowSizzler
{
public:
    CRowSizzler(int pW,int pBefore,int pAfter)
    {
        mW=pW;
        mJump=(mW-(mW+3)/4-pBefore-pAfter)/3;
        mPart=mW-3*mJump;
        mAfter=pAfter;
    }

    int GetSourceW() const   {   return mW;      }
    int GetPartW() const     {   return mPart;   }
    int GetTotalW() const    {   return mPart*4; }
    int GetJump() const      {   return mJump;   }

    void Sizzle(const float *pSrc,float *pDst) const;
    void Sizzle(const unsigned char *pSrc,float *pDst) const;
    void DeSizzle(const float *pSrc,float *pDst) const;
    void DeSizzle(const float *pSrc,unsigned char *pDst) const;

private:
    int mW;
    int mJump;
    int mPart;
    int mAfter;
};

void sizzle_lowpass_x(float *pSrc,float *pDst,const CRowSizzler &pSizzler);
void sizzle_first_lowpass_y(float *pSrc, float *pDst1, float *pDst2,
                            float *pDst3, float *pDst4, float *pDst5, const CRowSizzler &pSizzler);
void sizzle_lowpass_y(float *pSrc, float *pDst1, float *pDst2,
                      float *pDst3, float *pDst4, float *pDst5, const CRowSizzler &pSizzler);
void sizzle_sobel(float *pSrc1,float *pSrc2,float *pSrc3,float *pDstXX,float *pDstXY,float *pDstYY,
                  const CRowSizzler &pSizzler);
void sizzle_laplace(float *pSrc1,float *pSrc2,float *pSrc3,float *pDst,const CRowSizzler &pSizzler);
void sizzle_sum_window_first(float *pSrc, float *pDst,int pWS,bool pZero,const CRowSizzler &pSizzler);
void sizzle_sum_window(float *pSrc1, float *pSrc2, float *pDst, int pWS,const CRowSizzler &pSizzler);
void sizzle_harris(float *pSrcXX,float *pSrcXY,float *pSrcYY,float *pDst,float pHarrFac,const CRowSizzler &pSizzler);
void sizzle_harris_find_peak(float *pSrc1,float *pSrc2,float *pSrc3,float *pDst,
                             float pThresh,int pY,std::vector<std::pair<CPoint_d,float>> &pPeaks,const CRowSizzler &pSizzler);

/*namespace cvi*/ } /*namespace buola*/ }

#endif /* CROWSIZZLER_H_ */
